package  com.na.onlineservey.interview
import com.docu.common.Action
import com.docu.common.Message
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import com.na.onlineservey.InterviewService
import com.na.onlineservey.Interview

@Component("updateInterviewAction")
class UpdateInterviewAction extends Action {
  @Autowired
  InterviewService interviewInstanceService

   public Object preCondition(Object params, Object object) {
    Interview interviewInstance = Interview.read(Long.parseLong(params?.id?.toString()))
    interviewInstance.properties=params
    if (!interviewInstance.validate()) {
      return null
    }
    return interviewInstance
  }

   public Object postCondition(Object params, Object object) {
    //not implement
    return null
  }

   public Object execute(Object params, Object object) {
    try {
      return interviewInstanceService.update(object)
    } catch (Exception ex) {
      log.error(ex.message)
      return null
    }
  }
}
